﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo1
{
    struct PersonStruct
    { 
        public string name;
        public int phone;
        public string address;
    }
    class PersonClass
    {
        public string Name { get; set; }
        public int Phone { get; set; }
        public string Address { get; set; }
        static void Main(string[] args)
        {
            //定义一个结构体，名为 PersonStruct，有三个成员变量：姓名、电话、地址，
            //在主方法中，创建一个PersonStruct结构体对象p1，为p1的成员变量赋值。
            //再声明一个PersonStruct结构体变量p2，把p1赋值给p2，改变p2的姓名，打印p1的内容。

            //定义一个类，名为 PersonClass，有三个成员变量：姓名、电话、地址，
            //在主方法中，创建一个PersonClass对象p3，为p3的成员变量赋值。
            //再声明一个PersonClass变量p4，把p3赋值给p4，改变p4的姓名，打印p3的内容。

            //观察打印结果，并在在注释中，说下你对此的认识（它们为什么会这样？）

            //结构体
            PersonStruct P1 = new PersonStruct();
            P1.name = "张三";
            P1.phone = 10086;
            P1.address = "龙岩";
            Console.WriteLine("P1:"+P1.name+"\t"+P1.phone+"\t"+P1.address);

            PersonStruct P2 = new PersonStruct();
            P2 = P1;
            P2.name = "李四";
            P2.phone = 10010;
            P2.address = "厦门";
            Console.WriteLine("P2:" + P2.name + "\t" + P2.phone + "\t" + P2.address);
            Console.WriteLine("P1:" + P1.name + "\t" + P1.phone + "\t" + P1.address);

            //类
            PersonClass P3 = new PersonClass();
            P3.Name = "王五";
            P3.Phone = 1008611;
            P3.Address = "三明";
            Console.WriteLine("P3:" + P3.Name + "\t" + P3.Phone + "\t" + P3.Address);

            PersonClass P4 = new PersonClass();
            P4 = P3;
            P4.Name = "刘六";
            P4.Phone = 1001010;
            P4.Address = "泉州";
            Console.WriteLine("P4:" + P4.Name + "\t" + P4.Phone + "\t" + P4.Address);
            Console.WriteLine("P3:" + P3.Name + "\t" + P3.Phone + "\t" + P3.Address);

            //存储方式不同
        }
    }
}
